import requests
from api.global_conf import BASEURL, LOGPATH, CSVPATH
from utils.index import Logs

log = Logs(LOGPATH)


"""
register({
    "mobile": "13355566455",
    "password": "a123456",
    "client": 5
})
"""


def register(json):
    try:
        res = requests.post(BASEURL+'/api/account/register', json=json)
    except Exception as result:
        log.err(f'注册接口访问失败: /api/account/register \n报错信息: {result}')
    else:
        log.info(f'注册接口访问成功: /api/account/register \n返回数据: {res.text}')
        return res

def login(json):
    try:
        res = requests.post(BASEURL+'/api/account/login', json=json)
    except Exception as result:
        log.err(f'登录接口访问失败: /api/account/login \n报错信息: {result}')
    else:
        log.info(f'登录接口访问成功: /api/account/login \n返回数据: {res.text}')
        return res


